﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows.Markup;

namespace WpfApplication_Test
{
	public class EnumConverter : MarkupExtension, IValueConverter
	{
		public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			TestEnum s = (TestEnum)value;
			return s == (TestEnum)int.Parse(parameter.ToString());
		}

		public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
		{
			bool isChecked = (bool)value;
			if (!isChecked)
			{
				return null;
			}
			return (TestEnum)int.Parse(parameter.ToString());
		}

		public override object ProvideValue(IServiceProvider serviceProvider)
		{
			return this;
		}
	}
}
